package com.jiot.controller.order;

import com.zg.cloud.BaseResponse;
import com.zg.cloud.annotation.TokenCheck;
import com.zg.cloud.service.WorkOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import req.order.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author liling
 * @date 2020/10/19 14:42
 * @description
 **/
@RestController
@RequestMapping("/order/work")
@Api(value = "工单模块")
public class WorkOrderController {

    @Resource
    private WorkOrderService workOrderService;

    @PostMapping("/app/add")
    @TokenCheck
    @ApiOperation(value = "app用户新增工单", notes = "order")
    public BaseResponse appAdd(@RequestBody @Valid AppAddWorkOrderReq appAddWorkOrderReq) {
        workOrderService.appAdd(appAddWorkOrderReq);
        return new BaseResponse();
    }

    @PostMapping("/app/list")
    @TokenCheck
    @ApiOperation(value = "app用户工单列表", notes = "order")
    public BaseResponse appList(@RequestBody @Valid AppGetWorkOrderListReq appGetWorkOrderListReq) {
        return new BaseResponse(workOrderService.appList(appGetWorkOrderListReq));
    }

    @PostMapping("/app/info")
    @TokenCheck
    @ApiOperation(value = "app用户工单详情", notes = "order")
    public BaseResponse appInfo(@RequestBody @Valid AppGetWorkOrderInfoReq appGetWorkOrderInfoReq) {
        return new BaseResponse(workOrderService.appInfo(appGetWorkOrderInfoReq));
    }

    @PostMapping("/app/add/check")
    @TokenCheck
    @ApiOperation(value = "app用户请求巡检", notes = "order")
    public BaseResponse appAddCheck(@RequestBody @Valid AppAddCheckOrderReq appAddCheckOrderReq) {
        workOrderService.appAddCheck(appAddCheckOrderReq);
        return new BaseResponse();
    }

    @PostMapping("/app/install")
    @TokenCheck
    @ApiOperation(value = "app用户请求新装工单", notes = "order")
    public BaseResponse appInstall(@RequestBody @Valid AppAddInstallOrderReq appAddInstallOrderReq) {
        workOrderService.appInstall(appAddInstallOrderReq);
        return new BaseResponse();
    }
}
